<%@ page language="java" import="java.util.*,entity.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'subjects.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
	<script>
	 $(function(){
	 	$("input[name=p]").keydown(function(e){
	 		//alert(e.keyCode);//13
	 		if(e.keyCode==13){
	 		   location="subjectServlet?p="+$(this).val();
	 		}
	 	}).blur(function(){
	 		location="subjectServlet?p="+$(this).val(); 
	 	});
	 });
	</script>
  </head>
  
  <body>
    <h1>课程列表</h1>
    <c:
    <%
    	List<Subject> list=(List<Subject>)request.getAttribute("datas");
    	Integer totalPages=(Integer)request.getAttribute("totalPages");
    	
    	Integer pageNo=(Integer)request.getAttribute("pageNo");
     %>
     <table border="1" cellpadding="0" cellspacing="0">
     	<tr>
     	 <td>课程号</td><td>课程名</td><td>学时</td><td>年级</td>
     	</tr>
     	<%
     	 for(Subject s:list){
     	 %>
     	 <tr>
     	 <td><%=s.getId()%></td><td><%=s.getSubjectname() %></td><td><%=s.getClassHour() %></td><td><%=s.getGradeid()%></td>
     	</tr>
     	 <%} %>
     </table>
     <p>
     <a href="subjectServlet?p=1">首页</a>
     <a href="subjectServlet?p=<%=pageNo-1%>">上一页</a>
     <input type="number"  size="4" style="width:30px" name="p" value="<%=pageNo%>"/>
     <a href="subjectServlet?p=<%=pageNo+1%>">下一页</a>
     <a href="subjectServlet?p=<%=totalPages%>">尾页</a>
     </p>
  </body>
</html>
